home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #2 / Ham Radio 2000 - Volume 2.iso / HAMV2 / TCP_IP / TNOS230S / LAPB.H < prev    next >
C/C++ Source or Header  |  1997-09-14  |  6KB  |  163 lines

  1. #ifndef    _LAPB_H
  2. #define    _LAPB_H
  3.  
  4. #ifndef    _GLOBAL_H
  5. #include "global.h"
  6. #endif
  7.  
  8. #ifndef    _MBUF_H
  9. #include "mbuf.h"
  10. #endif
  11.  
  12. #ifndef    _IFACE_H
  13. #include "iface.h"
  14. #endif
  15.  
  16. #ifndef    _TIMER_H
  17. #include "timer.h"
  18. #endif
  19.  
  20. #ifndef    _AX25_H
  21. #include "ax25.h"
  22. #endif
  23.  
  24. /* Upper sub-layer (LAPB) definitions */
  25.  
  26. /* Control field templates */
  27. #define    I    0x00    /* Information frames */
  28. #define    S    0x01    /* Supervisory frames */
  29. #define    RR    0x01    /* Receiver ready */
  30. #define    RNR    0x05    /* Receiver not ready */
  31. #define    REJ    0x09    /* Reject */
  32. #define    U    0x03    /* Unnumbered frames */
  33. #define    SABM    0x2f    /* Set Asynchronous Balanced Mode */
  34. #define    DISC    0x43    /* Disconnect */
  35. #define    DM    0x0f    /* Disconnected mode */
  36. #define    UA    0x63    /* Unnumbered acknowledge */
  37. #define    FRMR    0x87    /* Frame reject */
  38. #define    UI    0x03    /* Unnumbered information */
  39. #define    PF    0x10    /* Poll/final bit */
  40.  
  41. #define    MMASK    7    /* Mask for modulo-8 sequence numbers */
  42.  
  43. /* FRMR reason bits */
  44. #define    W    1    /* Invalid control field */
  45. #define    X    2    /* Unallowed I-field */
  46. #define    Y    4    /* Too-long I-field */
  47. #define    Z    8    /* Invalid sequence number */
  48.  
  49. /* Per-connection link control block
  50.  * These are created and destroyed dynamically,
  51.  * and are indexed through a hash table.
  52.  * One exists for each logical AX.25 Level 2 connection
  53.  */
  54. struct ax25_cb {
  55.     struct ax25_cb *next;        /* Linked list pointers */
  56.  
  57.     struct iface *iface;        /* Interface */
  58.  
  59.     struct mbuf *txq;        /* Transmit queue */
  60.     struct mbuf *rxasm;        /* Receive reassembly buffer */
  61.     struct mbuf *rxq;        /* Receive queue */
  62.  
  63.     char local[AXALEN];        /* Addresses */
  64.     char remote[AXALEN];
  65.  
  66.     struct {
  67.         char rejsent;        /* REJ frame has been sent */
  68.         char remotebusy;    /* Remote sent RNR */
  69.         char rtt_run;        /* Round trip "timer" is running */
  70.         char retrans;        /* A retransmission has occurred */
  71.         char clone;         /* Server-type cb, will be cloned */
  72.         char rxd_I_frame;   /* I-frame received */
  73.     } flags;
  74.  
  75.     char reason;            /* Reason for connection closing */
  76. #define    LB_NORMAL    0        /* Normal close */
  77. #define    LB_DM        1        /* Received DM from other end */
  78. #define    LB_TIMEOUT    2        /* Excessive retries */
  79. #define LB_UNUSED    3        /* Link is redundant - unused */
  80.  
  81.     char response;            /* Response owed to other end */
  82.     char vs;            /* Our send state variable */
  83.     char vr;            /* Our receive state variable */
  84.     char unack;            /* Number of unacked frames */
  85.     int maxframe;            /* Transmit flow control level, frames */
  86.     int16 paclen;            /* Maximum outbound packet size, bytes */
  87.     int16 window;            /* Local flow control limit, bytes */
  88.     char proto;            /* Protocol version */
  89. #define    V1    1            /* AX.25 Version 1 */
  90. #define    V2    2            /* AX.25 Version 2 */
  91.     int16 pthresh;            /* Poll threshold, bytes */
  92.     unsigned retries;        /* Retry counter */
  93.     unsigned n2;            /* Retry limit */
  94.     int state;            /* Link state */
  95. #define    LAPB_DISCONNECTED    1
  96. #define LAPB_LISTEN        2
  97. #define    LAPB_SETUP        3
  98. #define    LAPB_DISCPENDING    4
  99. #define    LAPB_CONNECTED        5
  100. #define    LAPB_RECOVERY        6
  101.     struct timer t1;        /* Retry timer */
  102.     struct timer t3;        /* Keep-alive poll timer */
  103.     struct timer t4;        /* Link redundancy timer */
  104.     int32 rtt_time;            /* Stored clock values for RTT, ticks */
  105.     int rtt_seq;            /* Sequence number being timed */
  106.     int32 srt;            /* Smoothed round-trip time, ms */
  107.     int32 mdev;            /* Mean rtt deviation, ms */
  108.  
  109.     void (*r_upcall) (struct ax25_cb *,int);    /* Receiver upcall */
  110.     void (*t_upcall) (struct ax25_cb *,int);    /* Transmit upcall */
  111.     void (*s_upcall) (struct ax25_cb *,int,int);    /* State change upcall */
  112.  
  113.     int user;            /* User pointer */
  114.     int segremain;            /* Segmenter state */
  115.     int jumpstarted;    /* Was this one jumpstarted ? */
  116. #define KNOWN_LINK  1       /* incoming conn. is already known in cb list */
  117. #define NETROM_LINK 2       /* new connection to netrom interface call */
  118. #define ALIAS_LINK  4       /* new connection to alias call */
  119. #define CONF_LINK   8       /* new connection to conference call */
  120. #define IFACE_LINK  16      /* new connection to the interface call */
  121. #define IP_LINK     32      /* new connection to the IP call (VC) */
  122. #define NR4_LINK    64
  123. #define TELNET_LINK 128
  124. #define JUMPSTARTED 256     /* jumpstart was used */
  125. #define TUTOR_LINK  512     /* new connection to tutorial call */
  126. #define INFO_LINK   1024    /* new connection to info call */
  127. #define NEWS_LINK   2048    /* new connection to news call */
  128. #define RLOGIN_LINK 4096    /* sysop rlogin connection */
  129. #define TIP_LINK    8192
  130. #define TTY_LINK    16384   /* new connection to the ttylink call */
  131. #define NODE_LINK   32768   /* new connection to the node call */
  132.     struct ax_route *route;    /* route connection was created with */
  133. };
  134. #define    NULLAX25    ((struct ax25_cb *)0)
  135. extern struct ax25_cb *Ax25_cb;
  136. extern const char *Ax25states[],*Axreasons[];
  137. extern int32 Axirtt,T3init,T4init,Blimit;
  138. extern int16 N2,Maxframe,Paclen,Pthresh,Axwindow,Axversion;
  139.  
  140. /* In lapb.c: */
  141. void est_link (struct ax25_cb *axp);
  142. void lapbstate (struct ax25_cb *axp,int s);
  143. int lapb_input (struct ax25_cb *axp,int cmdrsp,struct mbuf *bp);
  144. int lapb_output (struct ax25_cb *axp);
  145. struct mbuf *segmenter (struct mbuf *bp,int16 ssize, struct ax25_cb *axp);
  146. int sendctl (struct ax25_cb *axp,int cmdrsp,int cmd);
  147.  
  148. /* In lapbtimer.c: */
  149. void pollthem (void *p);
  150. void recover (void *p);
  151. void redundant (void *p);
  152.  
  153. /* In ax25subr.c: */
  154. int16 ftype (int control);
  155. #ifdef MSDOS
  156. void lapb_garbage (int drastic);
  157. #endif
  158.  
  159. /* In nr3.c: */
  160. void nr_derate ( struct ax25_cb *axp);
  161.  
  162. #endif    /* _LAPB_H */
  163.